-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Enable cast string to int tests and fix compatibility issue #453
Conversation
@@ -82,7 +82,7 @@ macro_rules! cast_utf8_to_int { | |||
for i in 0..len { | |||
if $array.is_null(i) { | |||
cast_array.append_null() | |||
} else if let Some(cast_value) = $cast_method($array.value(i).trim(), $eval_mode)? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We originally trimmed the input strings here, so error messages did not have access to the original inputs
|
||
if state == State::ParseSignAndDigits { | ||
if !parsed_sign { | ||
for (i, ch) in trimmed_str.char_indices() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We process the trimmed string here and we no longer need the logic for skipping leading and trailing whitespace
@@ -1070,7 +1050,7 @@ fn do_cast_string_to_int< | |||
if ch == '.' { | |||
if eval_mode == EvalMode::Legacy { | |||
// truncate decimal in legacy mode | |||
state = State::ParseFractionalDigits; | |||
parse_sign_and_digits = false; | |||
continue; | |||
} else { | |||
return none_or_err(eval_mode, type_name, str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error messages refer to the original input string, not the trimmed version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending CI
So do you thing the perf improvement is because we are no longer trimming? |
We are still trimming, but we are no longer performing the redundant conditional logic in the main loop to skip leading and trailing whitespace. |
Which issue does this PR close?
Closes #431
Rationale for this change
Enable cast string to int as a compatible expression.
Also, there is a performance improvement with these changes:
What changes are included in this PR?
How are these changes tested?
Enabled the tests that were previously disabled